package com.milian.jdbc.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Author milian
 * @Date 2021/8/19 0019 16:29
 */
public class test1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        // 注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        // 获取连接
        String url = "jdbc:mysql://127.0.0.1:3306/db10?useSSL=false";
        String username="root";
        String password="root";
        Connection conn = DriverManager.getConnection(url, username, password);
        // 定义sql
        String sql = "update stu set age=51 where id=1";
        // 获取执行sql的对象statement
        Statement stmt = conn.createStatement();
        int count = stmt.executeUpdate(sql);
        System.out.println(count);
        stmt.close();
        conn.close();


    }
}
